/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.naotebuk.modelo;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.springframework.format.annotation.DateTimeFormat;

/**
 *
 * @author giovanni
 */
@Entity
@Table(name = "Cliente")
//@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cliente.listar", query = "SELECT c FROM Cliente c"),
    @NamedQuery(name = "Cliente.buscaPorId", query = "SELECT c FROM Cliente c WHERE c.id = :id"),
    @NamedQuery(name = "Cliente.buscaPorNomeCompleto", query = "SELECT c FROM Cliente c WHERE c.nomeCompleto LIKE :nomeCompleto"),
    @NamedQuery(name = "Cliente.buscaPorCpf", query = "SELECT c FROM Cliente c WHERE c.cpf = :cpf"),
    @NamedQuery(name = "Cliente.buscaPorDataNascimento", query = "SELECT c FROM Cliente c WHERE c.dataNascimento = :dataNascimento"),
    @NamedQuery(name = "Cliente.buscaPorSexo", query = "SELECT c FROM Cliente c WHERE c.sexo = :sexo"),
    @NamedQuery(name = "Cliente.buscaPorEmail", query = "SELECT c FROM Cliente c WHERE c.email = :email")})
public class Cliente implements Serializable {
//    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "nomeCompleto")
    private String nomeCompleto;
    @Basic(optional = false)
    @Column(name = "cpf")
    private String cpf;
    @Column(name = "dataNascimento")
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(pattern="dd/MM/yyyy")
    private Date dataNascimento;
    @Basic(optional = false)
    @Column(name = "sexo")
    private String sexo;
    @Basic(optional = false)
    @Column(name = "email")
    private String email;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cliente")
//    private Collection<Pedido> pedidoCollection;
    @JoinColumn(name = "endereco", referencedColumnName = "id")
    @OneToOne(optional = false, cascade = CascadeType.ALL)
    private Endereco endereco;

//    public Cliente() {
//    }
//
//    public Cliente(Integer id) {
//        this.id = id;
//    }
//
//    public Cliente(Integer id, String nomeCompleto, String cpf, String sexo, String email) {
//        this.id = id;
//        this.nomeCompleto = nomeCompleto;
//        this.cpf = cpf;
//        this.sexo = sexo;
//        this.email = email;
//    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNomeCompleto() {
        return nomeCompleto;
    }

    public void setNomeCompleto(String nomeCompleto) {
        this.nomeCompleto = nomeCompleto;
    }

    public String getCpf() {
        return cpf;
    }

    public void setCpf(String cpf) {
        this.cpf = cpf;
    }

    public Date getDataNascimento() {
        return dataNascimento;
    }

    public void setDataNascimento(Date dataNascimento) {
        this.dataNascimento = dataNascimento;
    }

    public String getSexo() {
        return sexo;
    }

    public void setSexo(String sexo) {
        this.sexo = sexo;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

//    @XmlTransient
//    public Collection<Pedido> getPedidoCollection() {
//        return pedidoCollection;
//    }
//
//    public void setPedidoCollection(Collection<Pedido> pedidoCollection) {
//        this.pedidoCollection = pedidoCollection;
//    }

    public Endereco getEndereco() {
        return endereco;
    }

    public void setEndereco(Endereco endereco) {
        this.endereco = endereco;
    }

//    @Override
//    public int hashCode() {
//        int hash = 0;
//        hash += (id != null ? id.hashCode() : 0);
//        return hash;
//    }
//
//    @Override
//    public boolean equals(Object object) {
//        // TODO: Warning - this method won't work in the case the id fields are not set
//        if (!(object instanceof Cliente)) {
//            return false;
//        }
//        Cliente other = (Cliente) object;
//        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
//            return false;
//        }
//        return true;
//    }
//
//    @Override
//    public String toString() {
//        return "br.com.naotebuk.modelo.Cliente[ id=" + id + " ]";
//    }
    
}
